package client;

import java.io.IOException;
import java.net.Socket;

import stream.StreamUtils;

public class SocketClient {
    public static void main(String args[]) {
        // 要连接的服务端IP地址和端口
        String host = "127.0.0.1";
        int port = 1828;
        // 与服务端建立连接
        SimpleSocketClient build = new SimpleSocketClient.Builder()
                .setServerHost(host)
                .setPort(port)
                .build();
        build.connectServer(new SocketConnectionCallBack() {
            @Override
            public void onSocketConnectionSuccess(Socket socket) {
                //do what wanna
                try {
                    StreamUtils.writeStream(socket.getOutputStream(),"推给服务器的消息");
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onSocketConnectionError(String message) {
                System.out.println(message);
            }
        });


    }
}